package com.fzz.learning_forum.controller;

import com.fzz.learning_forum.domain.Course;
import com.fzz.learning_forum.service.CourseService;
import com.fzz.learning_forum.serviceImpl.CourseServiceImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
public class IndexController {

    @Autowired
    private CourseService courseService=new CourseServiceImpl();

    //登录界面
    @RequestMapping(value = "/")
    public String index()
    {
        return "comm/login";
    }

    //我参与的评论动态
    @RequestMapping(value = "/user/myCommentArticle")
    public String myCommentArticle()
    {
        return "client/myCommArti";
    }

    //我的班级
    @RequestMapping(value = "/user/Course/{page}/{id}")
    public String userClass(HttpSession session,@PathVariable(value = "id")Integer id,@PathVariable(value = "page")Integer page, @RequestParam(value = "count",defaultValue ="2")Integer count)
    {
        PageInfo<Course> courseList = courseService.selectAllCourse(page, count);
        session.setAttribute("courseList",courseList);
        PageInfo<Course> courseListById = courseService.selectCourseById(page, count,id);
        session.setAttribute("courseListById",courseListById);
        return "client/myCourse";
    }

    //创建班级
    @RequestMapping(value = "/teacher/createCourse")
    public String createClass()
    {
        return "client/create_course";
    }
}
